package com.leo.base_project.activity.module_Impl.chartImpl;

import android.os.Bundle;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.LimitLine;
import com.github.mikephil.charting.data.Entry;
import com.leo.base_project.databinding.ActivityLineChartTestBinding;
import com.leo.base_project.module.chart.LineChartModule;

import java.util.ArrayList;

public class LineChartTestActivity extends AppCompatActivity {

    ActivityLineChartTestBinding binding;
    LineChart chart;
    LineChartModule utils;
    ArrayList<Entry> entries;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityLineChartTestBinding.inflate(getLayoutInflater() );
        View root = binding.getRoot();
        setContentView(root);
        setLineChart();
    }

    private void setLineChart() {
        chart = binding.lineChart;
        entries = new ArrayList<>();
        utils = new LineChartModule(chart,entries,"测试",-1);
        LimitLine ll1 = utils.setLimitLine(10, "测试1");
        LimitLine ll2 = utils.setLimitLine(-10, "测试2");
        utils.bindLimitLine(ll1,true);
        utils.bindLimitLine(ll2,true);
        utils.setRange(30,-30);
        utils.addData(new Entry(0,1));
        utils.addData(new Entry(1,4));
        utils.addData(new Entry(2,5));
        utils.addData(new Entry(3,8));
    }
}